package com.bilibili.controller;

import com.bilibili.entity.PicCartoon;
import com.bilibili.entity.PicCategory;
import com.bilibili.entity.PicRegion;
import com.bilibili.service.PicCartoonService;
import com.bilibili.service.PicPageService;
import com.bilibili.service.PicUploadService;
import com.bilibili.vo.PicUploadPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("pic_upload")
public class PicUploadController {

    @Autowired
    private PicUploadService picUploadService;

    @Autowired
    private PicCartoonService picCartoonService;

    @Autowired
    private PicPageService picPageService;

    @RequestMapping(value = "category", method = RequestMethod.GET )
    public List<PicCategory> getPicCategory() {
        return picUploadService.getAllCategory();
    }

    @RequestMapping(value = "region", method = RequestMethod.GET )
    public List<PicRegion> getAllRegion() {
        return picUploadService.getAllRegion();
    }

    @RequestMapping(value = "{name}", method = RequestMethod.GET )
    public PicCartoon getAllRegion(@PathVariable("name") String name) {
        return picCartoonService.getCartoonByName(name);
    }

    @RequestMapping(value = "pages", method = RequestMethod.POST)
    public boolean addPage(@RequestBody PicUploadPageVo picUploadPageVo) {
        return picPageService.addPage(picUploadPageVo);
    }

}
